# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  helper :all # include all helpers, all the time
  include ApplicationHelper
  protect_from_forgery # See ActionController::RequestForgeryProtection for details

  # Scrub sensitive parameters from your log
  # filter_parameter_logging :password
  
  private
  
    def redirect_to_welcome
      redirect_to :controller => :welcome, :action => :index
    end

    def redirect_to_admin
      redirect_to :controller => :welcome, :action => :admin
    end
    
  protected

    def authenticate
      # You can choose Http Authentication to protect your application.
      # authenticate_or_request_with_http_basic do |username, password|
      #   username == "admin" && password == "woaiziyou"
      # end
      
      # Define admin? method in ApplicationHelper.
      unless admin?
        redirect_to :controller => "welcome", :action => "index"
      end
    end
              
end